package tests

import scala.collection.mutable.ListBuffer

class TestCase extends TestComposite {

  private var testsList = new ListBuffer[Test]
  private var beforesList = new ListBuffer[Statement]
  private var aftersList = new ListBuffer[Statement]

  def tests = testsList.readOnly
  def befores = beforesList.readOnly
  def afters = aftersList.readOnly

  def describe = null

  implicit def stringWrapper(description: String) = new TestStatement(description)

  def before(description: String) = {
    val before = BeforeStatement(description)
    beforesList + before
    before
  }

  def after(description: String) = {
    val after = AfterStatement(description)
    aftersList + after
    after
  }

  def test(description: String) = addTest(new TestStatement(description))

  def test(description: String, timeout: Long) = addTest(TimedOutTestStatement(description, timeout))

  def test(description: String, expected: Class[_ <: Throwable]) = addTest(ExpectExceptionStatement(description, expected))

  def skip(test: TestStatement) = addTest(test).skip
  def skip(description: String) = test(description).skip

  private def addTest(test: TestStatement) = {
    testsList + test
    test
  }

}